<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
    <title>Purple Admin</title>
    <!-- plugins:css -->
    <link rel="stylesheet" href="../../vendors/iconfonts/mdi/css/materialdesignicons.min.css"/>
    <link rel="stylesheet" href="../../vendors/css/vendor.bundle.base.css"/>
    <!-- endinject -->
    <!-- inject:css -->
    <link rel="stylesheet" href="../../css/style.css"/>
    <!-- endinject -->
    <link rel="shortcut icon" href="../../images/favicon.png"/>
    <style type="text/css">
        #Conframe {
            border: none;
            height: 100%;
            width: 100%;
        }

        ul li {
            list-style: none;
        }
    </style>
</head>
<body>
<div id="showTbody">
    <div class="col-sm-6 col-md-4 col-lg-3">
        <i class="mdi mdi-home menu-icon"></i>首页/权限/角色管理/权限设置
    </div>
    <div class="card-body">
        <h4 class="card-title" th:text="'当前角色:'+${currentRole.rName}"></h4>
        <span class="text-center">
                <button type="button" class="btn btn-primary btn-sm" id="editBtn">保存</button>
            </span>
        <span class="text-left">
                <a type="button" class="btn btn-warning btn-sm" href="/role/getRole">返回</a>
            </span>
        <div>
            <form class="form-inline" id="editMenuFrom">
                <input type="hidden" value="0" name="checkMenu"/>
                <!--权限选择列表-->
                <!--<div class="form-check form-check-primary">-->
                <!--<label class="form-check-label">-->
                <!--&lt;!&ndash;隐藏域保存部门id &ndash;&gt;-->
                <!--<input th:value="${emp.eId}" type="hidden"/>-->
                <!--<input th:value="${emp.enable}" name="empCheck" type="checkbox"-->
                <!--class="form-check-input" th:checked="checked"/>-->
                <!--是否启用-->
                <!--<i class="input-helper"></i></label>-->
                <!--</div>-->
                <ul>
                    <li th:each="oneMenu:${allMenu}" style="width: 1000px">
                        <input name="checkMenu" type="checkbox" class="form-check-input" th:value="${oneMenu.mId}"
                               th:text="${oneMenu.mName}"
                               th:attr="checked=${menuByRId.contains(oneMenu.mName)?true:false}"/>
                        <ul>
                            <li th:each="towMenu:${oneMenu.towList}">
                                <input name="checkMenu" type="checkbox" th:value="${towMenu.mId}"
                                       th:attr="checked=${menuByRId.contains(towMenu.mName)?true:false}"
                                       th:text="${towMenu.mName}"/>&emsp;&emsp;&emsp;&emsp;
                                <span th:each="three:${towMenu.threeList}">
                                    <input type="checkbox" name="checkMenu" th:value="${three.mId}"
                                           th:attr="checked=${menuByRId.contains(three.mName)?true:false}"
                                           th:text="${three.mName}"/>
                                </span>
                            </li>
                        </ul>
                    </li>
                    <li></li>
                </ul>
                <!--/权限选择列表-->
            </form>
            <!--隐藏域保存角色id-->
            <input type="hidden" th:value="${currentRole.rId}" id="editRId"/>
        </div>
    </div>

    <!--jquery-->
    <script src="../../js/jquery-1.8.3.min.js" type="text/javascript"></script>
    <!-- plugins:js -->
    <script src="../../vendors/js/vendor.bundle.base.js"></script>
    <script src="../../vendors/js/vendor.bundle.addons.js"></script>
    <!-- endinject -->
    <!-- Plugin js for this page-->
    <!-- End plugin js for this page-->
    <!-- inject:js -->
    <script src="../../js/off-canvas.js"></script>
    <script src="../../js/misc.js"></script>
    <!-- endinject -->
    <!-- Custom js for this page-->
    <script src="../../js/dashboard.js"></script>
    <!-- End custom js for this page-->
    <script type="text/javascript">
        $(function () {
            //编辑保存所选权限
            $("#editBtn").click(function () {
                var rId = $("#editRId").val();
                $.ajax({
                    "url": "/menuManage/editMenu?menuList=" + $("#editMenuFrom").serialize(),
                    "type": "post",
                    "data": {"rId": rId},
                    "dataType": "json",
                    success: function (data) {
                        alert(data.msg);
                        window.location.href = "/role/getRole";
                    },
                    error: function (e) {
                        alert("回调ajax异常")
                    }
                });
            });


        });


    </script>
</div>
</body>

</html>
